import sys

sys.path.append("../dist/lib")

import formatters.wiki04 as wiki

formatter = wiki.WikiFormatter("")

assert formatter.format("[image:foo b\"ar]") == '<p><img src="foo" alt="b&quot;ar"/></p>'


assert formatter.format(r" [foo] ") == '<p> <a href="foo">foo</a> </p>'
assert formatter.format(r" [foo bar] ") == '<p> <a href="foo_bar">foo bar</a> </p>'
assert formatter.format(r" [foo_bar] ") == '<p> <a href="foo_bar">foo_bar</a> </p>'
assert formatter.format(r" [foo,bar] ") == '<p> <a href="foo,bar">foo,bar</a> </p>'
assert formatter.format(r" \[foo,bar] ") == '<p> \[foo,bar] </p>'
assert formatter.format(r" [[foo]] ") == '<p> <a href="[foo">[foo</a>] </p>'
assert formatter.format(r" [[foo\]] ") == '<p> <a href="[foo]">[foo]</a> </p>'
assert formatter.format(r" [foo\\bar\] ") == r'<p> [foo\\bar\] </p>'
assert formatter.format(r" [foo\\bar] ") == r'<p> <a href="foo\bar">foo\bar</a> </p>'


assert formatter.format("[amazon:1234567890 test]") == '<p><a href="http://www.amazon.com/exec/obidos/tg/detail/-/1234567890">test</a></p>'
assert formatter.format("[amazon:123456789X test]") == '<p><a href="http://www.amazon.com/exec/obidos/tg/detail/-/123456789X">test</a></p>'